	

   function loadResources()
   {
	  var image1 = new Image();
	  image1.onload = resourceTiming;
	  image1.src = 'https://www.w3.org/Icons/w3c_main.png';
   }

   window.onload= function()
   {
	   var resourceList = window.performance.getEntriesByType("resource");
	   console.log(resourceList);
	   for (i = 0; i < resourceList.length; i++)
	   {	   
			console.log("load time- "+resourceList[i].name+":"+ (resourceList[i].responseEnd - resourceList[i].startTime)+" ms");
			var data = {"name":resourceList[i].name,"time":(resourceList[i].responseEnd - resourceList[i].startTime)};
		    send(JSON.stringify(data));
	   }
   }
   
   function send(data) {
		var url = "http://152.136.209.130:9099/rest/resourcesTime/add";
        // 发送ajax
        // （1） 获取 XMLHttpRequest对象
        xmlHttp = new XMLHttpRequest();
        //  (2) 连接服务器
        //  get
        //xmlHttp.open("get","/sendAjax/?a=1&b=2");
        //  post
        xmlHttp.open("post",url);
        // 设置请求头的Content-Type
        xmlHttp.setRequestHeader("Content-Type","application/json");
        // （3） 发送数据
        xmlHttp.send(data) ;   // 请求体数据
        // （4） 回调函数  success
        xmlHttp.onreadystatechange = function() {
            if(this.readyState==4 && this.status==200){
                console.log(this.responseText)

            }
        };
    }
  
